// run: $exec < input
#include <cstdio>
#include <algorithm>

long long const inf = (long long)(1) << 60;
int const maxn = 100100;
long long a[maxn], b[maxn];
int n, m;

template <class T>
T mabs(T a) { return a < 0 ? -a : a; }

int main()
{
	while (std::scanf("%d %d", &n, &m) != EOF) {
		for (int i = 1; i <= n; i++) std::scanf("%lld", &a[i]);
		for (int i = 1; i <= m; i++) std::scanf("%lld", &b[i]);
		std::sort(b + 1, b + m + 1);
		long long ans = 0;
		for (int i = 1; i <= n; i++) {
			int t = std::lower_bound(b + 1, b + m + 1, a[i]) - b;
			long long tmp = inf;
			if (t <= m) tmp = mabs(a[i] - b[t]);
			if (t != 1) tmp = std::min(tmp, mabs(a[i] - b[t - 1]));
			ans += tmp;
		}
		std::printf("%lld\n", ans);
	}
}

